#! /bin/bash
#文件全路径+文件名
filePath=$1
if test -z "$filePath"; then
    echo "filePath not should be null"
    echo "example: sh deploy.sh /test.jar root@127.0.0.1 ~/code"
    exit
fi

# 服务器用户名@ip
destServer=$2
if test -z "$destServer"; then
    echo "dest not should be null"
    echo "example: sh deploy.sh /test.jar root@127.0.0.1  ~/code"
    exit
fi
#服务器存放路径
destPath=$3
if test -z "$destPath"; then
    echo "destPath not should be null"
    echo "example: sh deploy.sh /test.jar root@127.0.0.1  ~/code"
    exit
fi
#scp命令
scpVar="scp ${filePath} ${destServer}:${destPath}"

#启动服务命令
sshVar="ssh ${destServer} && cd ${destPath} && nohup java -jar ${destPath##*/} &"

${scpVar}
${sshVar}



